1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566 |
- /*
- * Javassist, a Java-bytecode translator toolkit.
- * Copyright (C) 1999- Shigeru Chiba. All Rights Reserved.
- *
- * The contents of this file are subject to the Mozilla Public License Version
- * 1.1 (the "License"); you may not use this file except in compliance with
- * the License. Alternatively, the contents of this file may be used under
- * the terms of the GNU Lesser General Public License Version 2.1 or later,
- * or the Apache License Version 2.0.
- *
- * Software distributed under the License is distributed on an "AS IS" basis,
- * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
- * for the specific language governing rights and limitations under the
- * License.
- */
-
- package javassist.bytecode;
-
- import java.io.ByteArrayOutputStream;
- import java.io.DataInputStream;
- import java.io.DataOutputStream;
- import java.io.IOException;
- import java.io.PrintWriter;
- import java.util.HashMap;
- import java.util.HashSet;
- import java.util.Map;
- import java.util.Set;
-
- import javassist.CtClass;
-
- /**
- * Constant pool table.
- */
- public final class ConstPool
- {
- LongVector items;
- int numOfItems;
- int thisClassInfo;
- Map<ConstInfo,ConstInfo> itemsCache;
-
- /**
- * <code>CONSTANT_Class</code>
- */
- public static final int CONST_Class = ClassInfo.tag;
-
- /**
- * <code>CONSTANT_Fieldref</code>
- */
- public static final int CONST_Fieldref = FieldrefInfo.tag;
-
- /**
- * <code>CONSTANT_Methodref</code>
- */
- public static final int CONST_Methodref = MethodrefInfo.tag;
-
- /**
- * <code>CONSTANT_InterfaceMethodref</code>
- */
- public static final int CONST_InterfaceMethodref
- = InterfaceMethodrefInfo.tag;
-
- /**
- * <code>CONSTANT_String</code>
- */
- public static final int CONST_String = StringInfo.tag;
-
- /**
- * <code>CONSTANT_Integer</code>
- */
- public static final int CONST_Integer = IntegerInfo.tag;
-
- /**
- * <code>CONSTANT_Float</code>
- */
- public static final int CONST_Float = FloatInfo.tag;
-
- /**
- * <code>CONSTANT_Long</code>
- */
- public static final int CONST_Long = LongInfo.tag;
-
- /**
- * <code>CONSTANT_Double</code>
- */
- public static final int CONST_Double = DoubleInfo.tag;
-
- /**
- * <code>CONSTANT_NameAndType</code>
- */
- public static final int CONST_NameAndType = NameAndTypeInfo.tag;
-
- /**
- * <code>CONSTANT_Utf8</code>
- */
- public static final int CONST_Utf8 = Utf8Info.tag;
-
- /**
- * <code>CONSTANT_MethodHandle</code>
- */
- public static final int CONST_MethodHandle = MethodHandleInfo.tag;
-
- /**
- * <code>CONSTANT_MethodHandle</code>
- */
- public static final int CONST_MethodType = MethodTypeInfo.tag;
-
- /**
- * <code>CONSTANT_Dynamic</code>
- */
- public static final int CONST_Dynamic = DynamicInfo.tag;
-
- /**
- * <code>CONSTANT_DynamicCallSite</code>,
- * also known as <code>CONSTANT_InvokeDynamic</code>
- */
- public static final int CONST_DynamicCallSite = InvokeDynamicInfo.tag;
- public static final int CONST_InvokeDynamic = InvokeDynamicInfo.tag;
-
- /**
- * <code>CONSTANT_Module</code>
- */
- public static final int CONST_Module = ModuleInfo.tag;
-
- /**
- * <code>CONSTANT_Package</code>
- */
- public static final int CONST_Package = PackageInfo.tag;
-
- /**
- * Represents the class using this constant pool table.
- */
- public static final CtClass THIS = null;
-
- /**
- * <code>reference_kind</code> of <code>CONSTANT_MethodHandle_info</code>.
- */
- public static final int REF_getField = 1;
-
- /**
- * <code>reference_kind</code> of <code>CONSTANT_MethodHandle_info</code>.
- */
- public static final int REF_getStatic = 2;
-
- /**
- * <code>reference_kind</code> of <code>CONSTANT_MethodHandle_info</code>.
- */
- public static final int REF_putField = 3;
-
- /**
- * <code>reference_kind</code> of <code>CONSTANT_MethodHandle_info</code>.
- */
- public static final int REF_putStatic = 4;
-
- /**
- * <code>reference_kind</code> of <code>CONSTANT_MethodHandle_info</code>.
- */
- public static final int REF_invokeVirtual = 5;
-
- /**
- * <code>reference_kind</code> of <code>CONSTANT_MethodHandle_info</code>.
- */
- public static final int REF_invokeStatic = 6;
-
- /**
- * <code>reference_kind</code> of <code>CONSTANT_MethodHandle_info</code>.
- */
- public static final int REF_invokeSpecial = 7;
-
- /**
- * <code>reference_kind</code> of <code>CONSTANT_MethodHandle_info</code>.
- */
- public static final int REF_newInvokeSpecial = 8;
-
- /**
- * <code>reference_kind</code> of <code>CONSTANT_MethodHandle_info</code>.
- */
- public static final int REF_invokeInterface = 9;
-
- /**
- * Constructs a constant pool table.
- *
- * @param thisclass the name of the class using this constant
- * pool table
- */
- public ConstPool(String thisclass)
- {
- items = new LongVector();
- itemsCache = null;
- numOfItems = 0;
- addItem0(null); // index 0 is reserved by the JVM.
- thisClassInfo = addClassInfo(thisclass);
- }
-
- /**
- * Constructs a constant pool table from the given byte stream.
- *
- * @param in byte stream.
- */
- public ConstPool(DataInputStream in) throws IOException
- {
- itemsCache = null;
- thisClassInfo = 0;
- /* read() initializes items and numOfItems, and do addItem(null).
- */
- read(in);
- }
-
- void prune()
- {
- itemsCache = null;
- }
-
- /**
- * Returns the number of entries in this table.
- */
- public int getSize()
- {
- return numOfItems;
- }
-
- /**
- * Returns the name of the class using this constant pool table.
- */
- public String getClassName()
- {
- return getClassInfo(thisClassInfo);
- }
-
- /**
- * Returns the index of <code>CONSTANT_Class_info</code> structure
- * specifying the class using this constant pool table.
- */
- public int getThisClassInfo()
- {
- return thisClassInfo;
- }
-
- void setThisClassInfo(int i)
- {
- thisClassInfo = i;
- }
-
- ConstInfo getItem(int n)
- {
- return items.elementAt(n);
- }
-
- /**
- * Returns the <code>tag</code> field of the constant pool table
- * entry at the given index.
- *
- * @return either <code>CONST_Class</code>, <code>CONST_Fieldref</code>,
- * <code>CONST_Methodref</code>, or ...
- */
- public int getTag(int index)
- {
- return getItem(index).getTag();
- }
-
- /**
- * Reads <code>CONSTANT_Class_info</code> structure
- * at the given index.
- *
- * @return a fully-qualified class or interface name specified
- * by <code>name_index</code>. If the type is an array
- * type, this method returns an encoded name like
- * <code>[Ljava.lang.Object;</code> (note that the separators
- * are not slashes but dots).
- * @see javassist.ClassPool#getCtClass(String)
- */
- public String getClassInfo(int index)
- {
- ClassInfo c = (ClassInfo)getItem(index);
- if (c == null)
- return null;
- return Descriptor.toJavaName(getUtf8Info(c.name));
- }
-
- /**
- * Reads <code>CONSTANT_Class_info</code> structure
- * at the given index.
- *
- * @return the descriptor of the type specified
- * by <code>name_index</code>.
- * @see javassist.ClassPool#getCtClass(String)
- * @since 3.15
- */
- public String getClassInfoByDescriptor(int index)
- {
- ClassInfo c = (ClassInfo)getItem(index);
- if (c == null)
- return null;
- String className = getUtf8Info(c.name);
- if (className.charAt(0) == '[')
- return className;
- return Descriptor.of(className);
- }
-
- /**
- * Reads the <code>name_index</code> field of the
- * <code>CONSTANT_NameAndType_info</code> structure
- * at the given index.
- */
- public int getNameAndTypeName(int index)
- {
- NameAndTypeInfo ntinfo = (NameAndTypeInfo)getItem(index);
- return ntinfo.memberName;
- }
-
- /**
- * Reads the <code>descriptor_index</code> field of the
- * <code>CONSTANT_NameAndType_info</code> structure
- * at the given index.
- */
- public int getNameAndTypeDescriptor(int index)
- {
- NameAndTypeInfo ntinfo = (NameAndTypeInfo)getItem(index);
- return ntinfo.typeDescriptor;
- }
-
- /**
- * Reads the <code>class_index</code> field of the
- * <code>CONSTANT_Fieldref_info</code>,
- * <code>CONSTANT_Methodref_info</code>,
- * or <code>CONSTANT_Interfaceref_info</code>,
- * structure at the given index.
- *
- * @since 3.6
- */
- public int getMemberClass(int index)
- {
- MemberrefInfo minfo = (MemberrefInfo)getItem(index);
- return minfo.classIndex;
- }
-
- /**
- * Reads the <code>name_and_type_index</code> field of the
- * <code>CONSTANT_Fieldref_info</code>,
- * <code>CONSTANT_Methodref_info</code>,
- * or <code>CONSTANT_Interfaceref_info</code>,
- * structure at the given index.
- *
- * @since 3.6
- */
- public int getMemberNameAndType(int index)
- {
- MemberrefInfo minfo = (MemberrefInfo)getItem(index);
- return minfo.nameAndTypeIndex;
- }
-
- /**
- * Reads the <code>class_index</code> field of the
- * <code>CONSTANT_Fieldref_info</code> structure
- * at the given index.
- */
- public int getFieldrefClass(int index)
- {
- FieldrefInfo finfo = (FieldrefInfo)getItem(index);
- return finfo.classIndex;
- }
-
- /**
- * Reads the <code>class_index</code> field of the
- * <code>CONSTANT_Fieldref_info</code> structure
- * at the given index.
- *
- * @return the name of the class at that <code>class_index</code>.
- */
- public String getFieldrefClassName(int index)
- {
- FieldrefInfo f = (FieldrefInfo)getItem(index);
- if (f == null)
- return null;
- return getClassInfo(f.classIndex);
- }
-
- /**
- * Reads the <code>name_and_type_index</code> field of the
- * <code>CONSTANT_Fieldref_info</code> structure
- * at the given index.
- */
- public int getFieldrefNameAndType(int index)
- {
- FieldrefInfo finfo = (FieldrefInfo)getItem(index);
- return finfo.nameAndTypeIndex;
- }
-
- /**
- * Reads the <code>name_index</code> field of the
- * <code>CONSTANT_NameAndType_info</code> structure
- * indirectly specified by the given index.
- *
- * @param index an index to a <code>CONSTANT_Fieldref_info</code>.
- * @return the name of the field.
- */
- public String getFieldrefName(int index)
- {
- FieldrefInfo f = (FieldrefInfo)getItem(index);
- if (f == null)
- return null;
- NameAndTypeInfo n = (NameAndTypeInfo)getItem(f.nameAndTypeIndex);
- if(n == null)
- return null;
- return getUtf8Info(n.memberName);
- }
-
- /**
- * Reads the <code>descriptor_index</code> field of the
- * <code>CONSTANT_NameAndType_info</code> structure
- * indirectly specified by the given index.
- *
- * @param index an index to a <code>CONSTANT_Fieldref_info</code>.
- * @return the type descriptor of the field.
- */
- public String getFieldrefType(int index)
- {
- FieldrefInfo f = (FieldrefInfo)getItem(index);
- if (f == null)
- return null;
- NameAndTypeInfo n = (NameAndTypeInfo)getItem(f.nameAndTypeIndex);
- if(n == null)
- return null;
- return getUtf8Info(n.typeDescriptor);
- }
-
- /**
- * Reads the <code>class_index</code> field of the
- * <code>CONSTANT_Methodref_info</code> structure
- * at the given index.
- */
- public int getMethodrefClass(int index)
- {
- MemberrefInfo minfo = (MemberrefInfo)getItem(index);
- return minfo.classIndex;
- }
-
- /**
- * Reads the <code>class_index</code> field of the
- * <code>CONSTANT_Methodref_info</code> structure
- * at the given index.
- *
- * @return the name of the class at that <code>class_index</code>.
- */
- public String getMethodrefClassName(int index)
- {
- MemberrefInfo minfo = (MemberrefInfo)getItem(index);
- if (minfo == null)
- return null;
- return getClassInfo(minfo.classIndex);
- }
-
- /**
- * Reads the <code>name_and_type_index</code> field of the
- * <code>CONSTANT_Methodref_info</code> structure
- * at the given index.
- */
- public int getMethodrefNameAndType(int index)
- {
- MemberrefInfo minfo = (MemberrefInfo)getItem(index);
- return minfo.nameAndTypeIndex;
- }
-
- /**
- * Reads the <code>name_index</code> field of the
- * <code>CONSTANT_NameAndType_info</code> structure
- * indirectly specified by the given index.
- *
- * @param index an index to a <code>CONSTANT_Methodref_info</code>.
- * @return the name of the method.
- */
- public String getMethodrefName(int index)
- {
- MemberrefInfo minfo = (MemberrefInfo)getItem(index);
- if (minfo == null)
- return null;
- NameAndTypeInfo n
- = (NameAndTypeInfo)getItem(minfo.nameAndTypeIndex);
- if(n == null)
- return null;
- return getUtf8Info(n.memberName);
- }
-
- /**
- * Reads the <code>descriptor_index</code> field of the
- * <code>CONSTANT_NameAndType_info</code> structure
- * indirectly specified by the given index.
- *
- * @param index an index to a <code>CONSTANT_Methodref_info</code>.
- * @return the descriptor of the method.
- */
- public String getMethodrefType(int index)
- {
- MemberrefInfo minfo = (MemberrefInfo)getItem(index);
- if (minfo == null)
- return null;
- NameAndTypeInfo n
- = (NameAndTypeInfo)getItem(minfo.nameAndTypeIndex);
- if(n == null)
- return null;
- return getUtf8Info(n.typeDescriptor);
- }
-
- /**
- * Reads the <code>class_index</code> field of the
- * <code>CONSTANT_InterfaceMethodref_info</code> structure
- * at the given index.
- */
- public int getInterfaceMethodrefClass(int index)
- {
- MemberrefInfo minfo = (MemberrefInfo)getItem(index);
- return minfo.classIndex;
- }
-
- /**
- * Reads the <code>class_index</code> field of the
- * <code>CONSTANT_InterfaceMethodref_info</code> structure
- * at the given index.
- *
- * @return the name of the class at that <code>class_index</code>.
- */
- public String getInterfaceMethodrefClassName(int index)
- {
- MemberrefInfo minfo = (MemberrefInfo)getItem(index);
- return getClassInfo(minfo.classIndex);
- }
-
- /**
- * Reads the <code>name_and_type_index</code> field of the
- * <code>CONSTANT_InterfaceMethodref_info</code> structure
- * at the given index.
- */
- public int getInterfaceMethodrefNameAndType(int index)
- {
- MemberrefInfo minfo = (MemberrefInfo)getItem(index);
- return minfo.nameAndTypeIndex;
- }
-
- /**
- * Reads the <code>name_index</code> field of the
- * <code>CONSTANT_NameAndType_info</code> structure
- * indirectly specified by the given index.
- *
- * @param index an index to
- * a <code>CONSTANT_InterfaceMethodref_info</code>.
- * @return the name of the method.
- */
- public String getInterfaceMethodrefName(int index)
- {
- MemberrefInfo minfo = (MemberrefInfo)getItem(index);
- if (minfo == null)
- return null;
- NameAndTypeInfo n
- = (NameAndTypeInfo)getItem(minfo.nameAndTypeIndex);
- if(n == null)
- return null;
- return getUtf8Info(n.memberName);
- }
-
- /**
- * Reads the <code>descriptor_index</code> field of the
- * <code>CONSTANT_NameAndType_info</code> structure
- * indirectly specified by the given index.
- *
- * @param index an index to
- * a <code>CONSTANT_InterfaceMethodref_info</code>.
- * @return the descriptor of the method.
- */
- public String getInterfaceMethodrefType(int index)
- {
- MemberrefInfo minfo = (MemberrefInfo)getItem(index);
- if (minfo == null)
- return null;
- NameAndTypeInfo n
- = (NameAndTypeInfo)getItem(minfo.nameAndTypeIndex);
- if(n == null)
- return null;
- return getUtf8Info(n.typeDescriptor);
- }
- /**
- * Reads <code>CONSTANT_Integer_info</code>, <code>_Float_info</code>,
- * <code>_Long_info</code>, <code>_Double_info</code>, or
- * <code>_String_info</code> structure.
- * These are used with the LDC instruction.
- *
- * @return a <code>String</code> value or a wrapped primitive-type
- * value.
- */
- public Object getLdcValue(int index)
- {
- ConstInfo constInfo = this.getItem(index);
- Object value = null;
- if (constInfo instanceof StringInfo)
- value = this.getStringInfo(index);
- else if (constInfo instanceof FloatInfo)
- value = Float.valueOf(getFloatInfo(index));
- else if (constInfo instanceof IntegerInfo)
- value = Integer.valueOf(getIntegerInfo(index));
- else if (constInfo instanceof LongInfo)
- value = Long.valueOf(getLongInfo(index));
- else if (constInfo instanceof DoubleInfo)
- value = Double.valueOf(getDoubleInfo(index));
-
- return value;
- }
-
- /**
- * Reads <code>CONSTANT_Integer_info</code> structure
- * at the given index.
- *
- * @return the value specified by this entry.
- */
- public int getIntegerInfo(int index)
- {
- IntegerInfo i = (IntegerInfo)getItem(index);
- return i.value;
- }
-
- /**
- * Reads <code>CONSTANT_Float_info</code> structure
- * at the given index.
- *
- * @return the value specified by this entry.
- */
- public float getFloatInfo(int index)
- {
- FloatInfo i = (FloatInfo)getItem(index);
- return i.value;
- }
-
- /**
- * Reads <code>CONSTANT_Long_info</code> structure
- * at the given index.
- *
- * @return the value specified by this entry.
- */
- public long getLongInfo(int index)
- {
- LongInfo i = (LongInfo)getItem(index);
- return i.value;
- }
-
- /**
- * Reads <code>CONSTANT_Double_info</code> structure
- * at the given index.
- *
- * @return the value specified by this entry.
- */
- public double getDoubleInfo(int index)
- {
- DoubleInfo i = (DoubleInfo)getItem(index);
- return i.value;
- }
-
- /**
- * Reads <code>CONSTANT_String_info</code> structure
- * at the given index.
- *
- * @return the string specified by <code>string_index</code>.
- */
- public String getStringInfo(int index)
- {
- StringInfo si = (StringInfo)getItem(index);
- return getUtf8Info(si.string);
- }
-
- /**
- * Reads <code>CONSTANT_utf8_info</code> structure
- * at the given index.
- *
- * @return the string specified by this entry.
- */
- public String getUtf8Info(int index)
- {
- Utf8Info utf = (Utf8Info)getItem(index);
- return utf.string;
- }
-
- /**
- * Reads the <code>reference_kind</code> field of the
- * <code>CONSTANT_MethodHandle_info</code> structure
- * at the given index.
- *
- * @see #REF_getField
- * @see #REF_getStatic
- * @see #REF_invokeInterface
- * @see #REF_invokeSpecial
- * @see #REF_invokeStatic
- * @see #REF_invokeVirtual
- * @see #REF_newInvokeSpecial
- * @see #REF_putField
- * @see #REF_putStatic
- * @since 3.17
- */
- public int getMethodHandleKind(int index)
- {
- MethodHandleInfo mhinfo = (MethodHandleInfo)getItem(index);
- return mhinfo.refKind;
- }
-
- /**
- * Reads the <code>reference_index</code> field of the
- * <code>CONSTANT_MethodHandle_info</code> structure
- * at the given index.
- *
- * @since 3.17
- */
- public int getMethodHandleIndex(int index)
- {
- MethodHandleInfo mhinfo = (MethodHandleInfo)getItem(index);
- return mhinfo.refIndex;
- }
-
- /**
- * Reads the <code>descriptor_index</code> field of the
- * <code>CONSTANT_MethodType_info</code> structure
- * at the given index.
- *
- * @since 3.17
- */
- public int getMethodTypeInfo(int index)
- {
- MethodTypeInfo mtinfo = (MethodTypeInfo)getItem(index);
- return mtinfo.descriptor;
- }
-
- /**
- * Reads the <code>bootstrap_method_attr_index</code> field of the
- * <code>CONSTANT_InvokeDynamic_info</code> structure
- * at the given index.
- *
- * @since 3.17
- */
- public int getInvokeDynamicBootstrap(int index)
- {
- InvokeDynamicInfo iv = (InvokeDynamicInfo)getItem(index);
- return iv.bootstrap;
- }
-
- /**
- * Reads the <code>name_and_type_index</code> field of the
- * <code>CONSTANT_InvokeDynamic_info</code> structure
- * at the given index.
- *
- * @since 3.17
- */
- public int getInvokeDynamicNameAndType(int index)
- {
- InvokeDynamicInfo iv = (InvokeDynamicInfo)getItem(index);
- return iv.nameAndType;
- }
-
- /**
- * Reads the <code>descriptor_index</code> field of the
- * <code>CONSTANT_NameAndType_info</code> structure
- * indirectly specified by the given index.
- *
- * @param index an index to a <code>CONSTANT_InvokeDynamic_info</code>.
- * @return the descriptor of the bootstrap method.
- * @since 3.17
- */
- public String getInvokeDynamicType(int index)
- {
- InvokeDynamicInfo iv = (InvokeDynamicInfo)getItem(index);
- if (iv == null)
- return null;
- NameAndTypeInfo n = (NameAndTypeInfo)getItem(iv.nameAndType);
- if(n == null)
- return null;
- return getUtf8Info(n.typeDescriptor);
- }
-
- /**
- * Reads the <code>bootstrap_method_attr_index</code> field of the
- * <code>CONSTANT_Dynamic_info</code> structure
- * at the given index.
- *
- * @since 3.26
- */
- public int getDynamicBootstrap(int index)
- {
- DynamicInfo iv = (DynamicInfo)getItem(index);
- return iv.bootstrap;
- }
-
- /**
- * Reads the <code>name_and_type_index</code> field of the
- * <code>CONSTANT_Dynamic_info</code> structure
- * at the given index.
- *
- * @since 3.26
- */
- public int getDynamicNameAndType(int index)
- {
- DynamicInfo iv = (DynamicInfo)getItem(index);
- return iv.nameAndType;
- }
-
- /**
- * Reads the <code>descriptor_index</code> field of the
- * <code>CONSTANT_NameAndType_info</code> structure
- * indirectly specified by the given index.
- *
- * @param index an index to a <code>CONSTANT_Dynamic_info</code>.
- * @return the descriptor of the bootstrap method.
- * @since 3.26
- */
- public String getDynamicType(int index)
- {
- DynamicInfo iv = (DynamicInfo)getItem(index);
- if (iv == null)
- return null;
- NameAndTypeInfo n = (NameAndTypeInfo)getItem(iv.nameAndType);
- if(n == null)
- return null;
- return getUtf8Info(n.typeDescriptor);
- }
-
- /**
- * Reads the <code>name_index</code> field of the
- * <code>CONSTANT_Module_info</code> structure at the given index.
- *
- * @return the module name at <code>name_index</code>.
- * @since 3.22
- */
- public String getModuleInfo(int index)
- {
- ModuleInfo mi = (ModuleInfo)getItem(index);
- return getUtf8Info(mi.name);
- }
-
- /**
- * Reads the <code>name_index</code> field of the
- * <code>CONSTANT_Package_info</code> structure at the given index.
- *
- * @return the package name at <code>name_index</code>. It is a slash-
- * separated name such as com/oracle/net.
- * @since 3.22
- */
- public String getPackageInfo(int index)
- {
- PackageInfo mi = (PackageInfo)getItem(index);
- return getUtf8Info(mi.name);
- }
-
- /**
- * Determines whether <code>CONSTANT_Methodref_info</code>
- * structure at the given index represents the constructor
- * of the given class.
- *
- * @return the <code>descriptor_index</code> specifying
- * the type descriptor of the that constructor.
- * If it is not that constructor,
- * <code>isConstructor()</code> returns 0.
- */
- public int isConstructor(String classname, int index)
- {
- return isMember(classname, MethodInfo.nameInit, index);
- }
-
- /**
- * Determines whether <code>CONSTANT_Methodref_info</code>,
- * <code>CONSTANT_Fieldref_info</code>, or
- * <code>CONSTANT_InterfaceMethodref_info</code> structure
- * at the given index represents the member with the specified
- * name and declaring class.
- *
- * @param classname the class declaring the member
- * @param membername the member name
- * @param index the index into the constant pool table
- *
- * @return the <code>descriptor_index</code> specifying
- * the type descriptor of that member.
- * If it is not that member,
- * <code>isMember()</code> returns 0.
- */
- public int isMember(String classname, String membername, int index)
- {
- MemberrefInfo minfo = (MemberrefInfo)getItem(index);
- if (getClassInfo(minfo.classIndex).equals(classname)) {
- NameAndTypeInfo ntinfo
- = (NameAndTypeInfo)getItem(minfo.nameAndTypeIndex);
- if (getUtf8Info(ntinfo.memberName).equals(membername))
- return ntinfo.typeDescriptor;
- }
-
- return 0; // false
- }
-
- /**
- * Determines whether <code>CONSTANT_Methodref_info</code>,
- * <code>CONSTANT_Fieldref_info</code>, or
- * <code>CONSTANT_InterfaceMethodref_info</code> structure
- * at the given index has the name and the descriptor
- * given as the arguments.
- *
- * @param membername the member name
- * @param desc the descriptor of the member.
- * @param index the index into the constant pool table
- *
- * @return the name of the target class specified by
- * the <code>..._info</code> structure
- * at <code>index</code>.
- * Otherwise, null if that structure does not
- * match the given member name and descriptor.
- */
- public String eqMember(String membername, String desc, int index)
- {
- MemberrefInfo minfo = (MemberrefInfo)getItem(index);
- NameAndTypeInfo ntinfo
- = (NameAndTypeInfo)getItem(minfo.nameAndTypeIndex);
- if (getUtf8Info(ntinfo.memberName).equals(membername)
- && getUtf8Info(ntinfo.typeDescriptor).equals(desc))
- return getClassInfo(minfo.classIndex);
- return null; // false
- }
-
- private int addItem0(ConstInfo info)
- {
- items.addElement(info);
- return numOfItems++;
- }
-
- private int addItem(ConstInfo info)
- {
- if (itemsCache == null)
- itemsCache = makeItemsCache(items);
-
- ConstInfo found = itemsCache.get(info);
- if (found != null)
- return found.index;
- items.addElement(info);
- itemsCache.put(info, info);
- return numOfItems++;
- }
-
- /**
- * Copies the n-th item in this ConstPool object into the destination
- * ConstPool object.
- * The class names that the item refers to are renamed according
- * to the given map.
- *
- * @param n the <i>n</i>-th item
- * @param dest destination constant pool table
- * @param classnames the map or null.
- * @return the index of the copied item into the destination ClassPool.
- */
- public int copy(int n, ConstPool dest, Map<String,String> classnames)
- {
- if (n == 0)
- return 0;
-
- ConstInfo info = getItem(n);
- return info.copy(this, dest, classnames);
- }
-
- int addConstInfoPadding() {
- return addItem0(new ConstInfoPadding(numOfItems));
- }
-
- /**
- * Adds a new <code>CONSTANT_Class_info</code> structure.
- *
- * <p>This also adds a <code>CONSTANT_Utf8_info</code> structure
- * for storing the class name.
- *
- * @return the index of the added entry.
- */
- public int addClassInfo(CtClass c)
- {
- if (c == THIS)
- return thisClassInfo;
- else if (!c.isArray())
- return addClassInfo(c.getName());
- else {
- // an array type is recorded in the hashtable with
- // the key "[L<classname>;" instead of "<classname>".
- //
- // note: toJvmName(toJvmName(c)) is equal to toJvmName(c).
-
- return addClassInfo(Descriptor.toJvmName(c));
- }
- }
-
- /**
- * Adds a new <code>CONSTANT_Class_info</code> structure.
- *
- * <p>This also adds a <code>CONSTANT_Utf8_info</code> structure
- * for storing the class name.
- *
- * @param qname a fully-qualified class name
- * (or the JVM-internal representation of that name).
- * @return the index of the added entry.
- */
- public int addClassInfo(String qname)
- {
- int utf8 = addUtf8Info(Descriptor.toJvmName(qname));
- return addItem(new ClassInfo(utf8, numOfItems));
- }
-
- /**
- * Adds a new <code>CONSTANT_NameAndType_info</code> structure.
- *
- * <p>This also adds <code>CONSTANT_Utf8_info</code> structures.
- *
- * @param name <code>name_index</code>
- * @param type <code>descriptor_index</code>
- * @return the index of the added entry.
- */
- public int addNameAndTypeInfo(String name, String type)
- {
- return addNameAndTypeInfo(addUtf8Info(name), addUtf8Info(type));
- }
-
- /**
- * Adds a new <code>CONSTANT_NameAndType_info</code> structure.
- *
- * @param name <code>name_index</code>
- * @param type <code>descriptor_index</code>
- * @return the index of the added entry.
- */
- public int addNameAndTypeInfo(int name, int type)
- {
- return addItem(new NameAndTypeInfo(name, type, numOfItems));
- }
-
- /**
- * Adds a new <code>CONSTANT_Fieldref_info</code> structure.
- *
- * <p>This also adds a new <code>CONSTANT_NameAndType_info</code>
- * structure.
- *
- * @param classInfo <code>class_index</code>
- * @param name <code>name_index</code>
- * of <code>CONSTANT_NameAndType_info</code>.
- * @param type <code>descriptor_index</code>
- * of <code>CONSTANT_NameAndType_info</code>.
- * @return the index of the added entry.
- */
- public int addFieldrefInfo(int classInfo, String name, String type)
- {
- int nt = addNameAndTypeInfo(name, type);
- return addFieldrefInfo(classInfo, nt);
- }
-
- /**
- * Adds a new <code>CONSTANT_Fieldref_info</code> structure.
- *
- * @param classInfo <code>class_index</code>
- * @param nameAndTypeInfo <code>name_and_type_index</code>.
- * @return the index of the added entry.
- */
- public int addFieldrefInfo(int classInfo, int nameAndTypeInfo)
- {
- return addItem(new FieldrefInfo(classInfo, nameAndTypeInfo,
- numOfItems));
- }
-
- /**
- * Adds a new <code>CONSTANT_Methodref_info</code> structure.
- *
- * <p>This also adds a new <code>CONSTANT_NameAndType_info</code>
- * structure.
- *
- * @param classInfo <code>class_index</code>
- * @param name <code>name_index</code>
- * of <code>CONSTANT_NameAndType_info</code>.
- * @param type <code>descriptor_index</code>
- * of <code>CONSTANT_NameAndType_info</code>.
- * @return the index of the added entry.
- */
- public int addMethodrefInfo(int classInfo, String name, String type)
- {
- int nt = addNameAndTypeInfo(name, type);
- return addMethodrefInfo(classInfo, nt);
- }
-
- /**
- * Adds a new <code>CONSTANT_Methodref_info</code> structure.
- *
- * @param classInfo <code>class_index</code>
- * @param nameAndTypeInfo <code>name_and_type_index</code>.
- * @return the index of the added entry.
- */
- public int addMethodrefInfo(int classInfo, int nameAndTypeInfo)
- {
- return addItem(new MethodrefInfo(classInfo,
- nameAndTypeInfo, numOfItems));
- }
-
- /**
- * Adds a new <code>CONSTANT_InterfaceMethodref_info</code>
- * structure.
- *
- * <p>This also adds a new <code>CONSTANT_NameAndType_info</code>
- * structure.
- *
- * @param classInfo <code>class_index</code>
- * @param name <code>name_index</code>
- * of <code>CONSTANT_NameAndType_info</code>.
- * @param type <code>descriptor_index</code>
- * of <code>CONSTANT_NameAndType_info</code>.
- * @return the index of the added entry.
- */
- public int addInterfaceMethodrefInfo(int classInfo,
- String name,
- String type)
- {
- int nt = addNameAndTypeInfo(name, type);
- return addInterfaceMethodrefInfo(classInfo, nt);
- }
-
- /**
- * Adds a new <code>CONSTANT_InterfaceMethodref_info</code>
- * structure.
- *
- * @param classInfo <code>class_index</code>
- * @param nameAndTypeInfo <code>name_and_type_index</code>.
- * @return the index of the added entry.
- */
- public int addInterfaceMethodrefInfo(int classInfo,
- int nameAndTypeInfo)
- {
- return addItem(new InterfaceMethodrefInfo(classInfo,
- nameAndTypeInfo,
- numOfItems));
- }
-
- /**
- * Adds a new <code>CONSTANT_String_info</code>
- * structure.
- *
- * <p>This also adds a new <code>CONSTANT_Utf8_info</code>
- * structure.
- *
- * @return the index of the added entry.
- */
- public int addStringInfo(String str)
- {
- int utf = addUtf8Info(str);
- return addItem(new StringInfo(utf, numOfItems));
- }
-
- /**
- * Adds a new <code>CONSTANT_Integer_info</code>
- * structure.
- *
- * @return the index of the added entry.
- */
- public int addIntegerInfo(int i)
- {
- return addItem(new IntegerInfo(i, numOfItems));
- }
-
- /**
- * Adds a new <code>CONSTANT_Float_info</code>
- * structure.
- *
- * @return the index of the added entry.
- */
- public int addFloatInfo(float f)
- {
- return addItem(new FloatInfo(f, numOfItems));
- }
-
- /**
- * Adds a new <code>CONSTANT_Long_info</code>
- * structure.
- *
- * @return the index of the added entry.
- */
- public int addLongInfo(long l)
- {
- int i = addItem(new LongInfo(l, numOfItems));
- if (i == numOfItems - 1) // if not existing
- addConstInfoPadding();
-
- return i;
- }
-
- /**
- * Adds a new <code>CONSTANT_Double_info</code>
- * structure.
- *
- * @return the index of the added entry.
- */
- public int addDoubleInfo(double d)
- {
- int i = addItem(new DoubleInfo(d, numOfItems));
- if (i == numOfItems - 1) // if not existing
- addConstInfoPadding();
-
- return i;
- }
-
- /**
- * Adds a new <code>CONSTANT_Utf8_info</code>
- * structure.
- *
- * @return the index of the added entry.
- */
- public int addUtf8Info(String utf8)
- {
- return addItem(new Utf8Info(utf8, numOfItems));
- }
-
- /**
- * Adds a new <code>CONSTANT_MethodHandle_info</code>
- * structure.
- *
- * @param kind <code>reference_kind</code>
- * such as {@link #REF_invokeStatic <code>REF_invokeStatic</code>}.
- * @param index <code>reference_index</code>.
- * @return the index of the added entry.
- *
- * @since 3.17
- */
- public int addMethodHandleInfo(int kind, int index)
- {
- return addItem(new MethodHandleInfo(kind, index, numOfItems));
- }
-
- /**
- * Adds a new <code>CONSTANT_MethodType_info</code>
- * structure.
- *
- * @param desc <code>descriptor_index</code>.
- * @return the index of the added entry.
- *
- * @since 3.17
- */
- public int addMethodTypeInfo(int desc)
- {
- return addItem(new MethodTypeInfo(desc, numOfItems));
- }
-
- /**
- * Adds a new <code>CONSTANT_InvokeDynamic_info</code>
- * structure.
- *
- * @param bootstrap <code>bootstrap_method_attr_index</code>.
- * @param nameAndType <code>name_and_type_index</code>.
- * @return the index of the added entry.
- *
- * @since 3.17
- */
- public int addInvokeDynamicInfo(int bootstrap, int nameAndType)
- {
- return addItem(new InvokeDynamicInfo(bootstrap, nameAndType, numOfItems));
- }
-
- /**
- * Adds a new <code>CONSTANT_Dynamic_info</code> structure.
- *
- * @param bootstrap <code>bootstrap_method_attr_index</code>.
- * @param nameAndType <code>name_and_type_index</code>.
- * @return the index of the added entry.
- * @since 3.26
- */
- public int addDynamicInfo(int bootstrap, int nameAndType) {
- return addItem(new DynamicInfo(bootstrap, nameAndType, numOfItems));
- }
-
- /**
- * Adds a new <code>CONSTANT_Module_info</code>
- * @param nameIndex the index of the Utf8 entry.
- * @return the index of the added entry.
- * @since 3.22
- */
- public int addModuleInfo(int nameIndex)
- {
- return addItem(new ModuleInfo(nameIndex, numOfItems));
- }
-
- /**
- * Adds a new <code>CONSTANT_Package_info</code>
- * @param nameIndex the index of the Utf8 entry.
- * @return the index of the added entry.
- * @since 3.22
- */
- public int addPackageInfo(int nameIndex)
- {
- return addItem(new PackageInfo(nameIndex, numOfItems));
- }
-
- /**
- * Get all the class names.
- *
- * @return a set of class names (<code>String</code> objects).
- */
- public Set<String> getClassNames()
- {
- Set<String> result = new HashSet<String>();
- LongVector v = items;
- int size = numOfItems;
- for (int i = 1; i < size; ++i) {
- String className = v.elementAt(i).getClassName(this);
- if (className != null)
- result.add(className);
- }
- return result;
- }
-
- /**
- * Replaces all occurrences of a class name.
- *
- * @param oldName the replaced name (JVM-internal representation).
- * @param newName the substituted name (JVM-internal representation).
- */
- public void renameClass(String oldName, String newName)
- {
- LongVector v = items;
- int size = numOfItems;
- for (int i = 1; i < size; ++i) {
- ConstInfo ci = v.elementAt(i);
- ci.renameClass(this, oldName, newName, itemsCache);
- }
- }
-
- /**
- * Replaces all occurrences of class names.
- *
- * @param classnames specifies pairs of replaced and substituted
- * name.
- */
- public void renameClass(Map<String,String> classnames)
- {
- LongVector v = items;
- int size = numOfItems;
- for (int i = 1; i < size; ++i) {
- ConstInfo ci = v.elementAt(i);
- ci.renameClass(this, classnames, itemsCache);
- }
- }
-
- private void read(DataInputStream in) throws IOException
- {
- int n = in.readUnsignedShort();
-
- items = new LongVector(n);
- numOfItems = 0;
- addItem0(null); // index 0 is reserved by the JVM.
-
- while (--n > 0) { // index 0 is reserved by JVM
- int tag = readOne(in);
- if ((tag == LongInfo.tag) || (tag == DoubleInfo.tag)) {
- addConstInfoPadding();
- --n;
- }
- }
- }
-
- private static Map<ConstInfo,ConstInfo> makeItemsCache(LongVector items)
- {
- Map<ConstInfo,ConstInfo> cache = new HashMap<ConstInfo,ConstInfo>();
- int i = 1;
- while (true) {
- ConstInfo info = items.elementAt(i++);
- if (info == null)
- break;
- cache.put(info, info);
- }
-
- return cache;
- }
-
- private int readOne(DataInputStream in) throws IOException
- {
- ConstInfo info;
- int tag = in.readUnsignedByte();
- switch (tag) {
- case Utf8Info.tag : // 1
- info = new Utf8Info(in, numOfItems);
- break;
- case IntegerInfo.tag : // 3
- info = new IntegerInfo(in, numOfItems);
- break;
- case FloatInfo.tag : // 4
- info = new FloatInfo(in, numOfItems);
- break;
- case LongInfo.tag : // 5
- info = new LongInfo(in, numOfItems);
- break;
- case DoubleInfo.tag : // 6
- info = new DoubleInfo(in, numOfItems);
- break;
- case ClassInfo.tag : // 7
- info = new ClassInfo(in, numOfItems);
- break;
- case StringInfo.tag : // 8
- info = new StringInfo(in, numOfItems);
- break;
- case FieldrefInfo.tag : // 9
- info = new FieldrefInfo(in, numOfItems);
- break;
- case MethodrefInfo.tag : // 10
- info = new MethodrefInfo(in, numOfItems);
- break;
- case InterfaceMethodrefInfo.tag : // 11
- info = new InterfaceMethodrefInfo(in, numOfItems);
- break;
- case NameAndTypeInfo.tag : // 12
- info = new NameAndTypeInfo(in, numOfItems);
- break;
- case MethodHandleInfo.tag : // 15
- info = new MethodHandleInfo(in, numOfItems);
- break;
- case MethodTypeInfo.tag : // 16
- info = new MethodTypeInfo(in, numOfItems);
- break;
- case DynamicInfo.tag : // 17
- info = new DynamicInfo(in, numOfItems);
- break;
- case InvokeDynamicInfo.tag : // 18
- info = new InvokeDynamicInfo(in, numOfItems);
- break;
- case ModuleInfo.tag : // 19
- info = new ModuleInfo(in, numOfItems);
- break;
- case PackageInfo.tag : // 20
- info = new PackageInfo(in, numOfItems);
- break;
- default :
- throw new IOException("invalid constant type: "
- + tag + " at " + numOfItems);
- }
-
- addItem0(info);
- return tag;
- }
-
- /**
- * Writes the contents of the constant pool table.
- */
- public void write(DataOutputStream out) throws IOException
- {
- out.writeShort(numOfItems);
- LongVector v = items;
- int size = numOfItems;
- for (int i = 1; i < size; ++i)
- v.elementAt(i).write(out);
- }
-
- /**
- * Prints the contents of the constant pool table.
- */
- public void print()
- {
- print(new PrintWriter(System.out, true));
- }
-
- /**
- * Prints the contents of the constant pool table.
- */
- public void print(PrintWriter out)
- {
- int size = numOfItems;
- for (int i = 1; i < size; ++i) {
- out.print(i);
- out.print(" ");
- items.elementAt(i).print(out);
- }
- }
- }
-
- abstract class ConstInfo
- {
- int index;
-
- public ConstInfo(int i) { index = i; }
-
- public abstract int getTag();
-
- public String getClassName(ConstPool cp) { return null; }
- public void renameClass(ConstPool cp, String oldName, String newName,
- Map<ConstInfo,ConstInfo> cache) {}
- public void renameClass(ConstPool cp, Map<String,String> classnames,
- Map<ConstInfo,ConstInfo> cache) {}
- public abstract int copy(ConstPool src, ConstPool dest,
- Map<String, String> classnames);
- // ** classnames is a mapping between JVM names.
-
- public abstract void write(DataOutputStream out) throws IOException;
- public abstract void print(PrintWriter out);
-
- @Override
- public String toString() {
- ByteArrayOutputStream bout = new ByteArrayOutputStream();
- PrintWriter out = new PrintWriter(bout);
- print(out);
- return bout.toString();
- }
- }
-
- /* padding following DoubleInfo or LongInfo.
- */
- class ConstInfoPadding extends ConstInfo
- {
- public ConstInfoPadding(int i) { super(i); }
-
- @Override
- public int getTag() { return 0; }
-
- @Override
- public int copy(ConstPool src, ConstPool dest, Map<String,String> map)
- {
- return dest.addConstInfoPadding();
- }
-
- @Override
- public void write(DataOutputStream out) throws IOException {}
-
- @Override
- public void print(PrintWriter out)
- {
- out.println("padding");
- }
- }
-
- class ClassInfo extends ConstInfo
- {
- static final int tag = 7;
- int name;
-
- public ClassInfo(int className, int index)
- {
- super(index);
- name = className;
- }
-
- public ClassInfo(DataInputStream in, int index) throws IOException
- {
- super(index);
- name = in.readUnsignedShort();
- }
-
- @Override
- public int hashCode() { return name; }
-
- @Override
- public boolean equals(Object obj)
- {
- return obj instanceof ClassInfo && ((ClassInfo)obj).name == name;
- }
-
- @Override
- public int getTag() { return tag; }
-
- @Override
- public String getClassName(ConstPool cp)
- {
- return cp.getUtf8Info(name);
- }
-
- @Override
- public void renameClass(ConstPool cp, String oldName, String newName,
- Map<ConstInfo,ConstInfo> cache)
- {
- String nameStr = cp.getUtf8Info(name);
- String newNameStr = null;
- if (nameStr.equals(oldName))
- newNameStr = newName;
- else if (nameStr.charAt(0) == '[') {
- String s = Descriptor.rename(nameStr, oldName, newName);
- if (nameStr != s)
- newNameStr = s;
- }
-
- if (newNameStr != null)
- if (cache == null)
- name = cp.addUtf8Info(newNameStr);
- else {
- cache.remove(this);
- name = cp.addUtf8Info(newNameStr);
- cache.put(this, this);
- }
- }
-
- @Override
- public void renameClass(ConstPool cp, Map<String,String> map,
- Map<ConstInfo,ConstInfo> cache)
- {
- String oldName = cp.getUtf8Info(name);
- String newName = null;
- if (oldName.charAt(0) == '[') {
- String s = Descriptor.rename(oldName, map);
- if (oldName != s)
- newName = s;
- }
- else {
- String s = map.get(oldName);
- if (s != null && !s.equals(oldName))
- newName = s;
- }
-
- if (newName != null) {
- if (cache == null)
- name = cp.addUtf8Info(newName);
- else {
- cache.remove(this);
- name = cp.addUtf8Info(newName);
- cache.put(this, this);
- }
- }
- }
-
- @Override
- public int copy(ConstPool src, ConstPool dest, Map<String,String> map)
- {
- String classname = src.getUtf8Info(name);
- if (map != null) {
- String newname = map.get(classname);
- if (newname != null)
- classname = newname;
- }
-
- return dest.addClassInfo(classname);
- }
-
- @Override
- public void write(DataOutputStream out) throws IOException
- {
- out.writeByte(tag);
- out.writeShort(name);
- }
-
- @Override
- public void print(PrintWriter out)
- {
- out.print("Class #");
- out.println(name);
- }
- }
-
- class NameAndTypeInfo extends ConstInfo
- {
- static final int tag = 12;
- int memberName;
- int typeDescriptor;
-
- public NameAndTypeInfo(int name, int type, int index)
- {
- super(index);
- memberName = name;
- typeDescriptor = type;
- }
-
- public NameAndTypeInfo(DataInputStream in, int index) throws IOException
- {
- super(index);
- memberName = in.readUnsignedShort();
- typeDescriptor = in.readUnsignedShort();
- }
-
- @Override
- public int hashCode() { return (memberName << 16) ^ typeDescriptor; }
-
- @Override
- public boolean equals(Object obj)
- {
- if (obj instanceof NameAndTypeInfo) {
- NameAndTypeInfo nti = (NameAndTypeInfo)obj;
- return nti.memberName == memberName
- && nti.typeDescriptor == typeDescriptor;
- }
- return false;
- }
-
- @Override
- public int getTag() { return tag; }
-
- @Override
- public void renameClass(ConstPool cp, String oldName, String newName,
- Map<ConstInfo,ConstInfo> cache)
- {
- String type = cp.getUtf8Info(typeDescriptor);
- String type2 = Descriptor.rename(type, oldName, newName);
- if (type != type2)
- if (cache == null)
- typeDescriptor = cp.addUtf8Info(type2);
- else {
- cache.remove(this);
- typeDescriptor = cp.addUtf8Info(type2);
- cache.put(this, this);
- }
- }
-
- @Override
- public void renameClass(ConstPool cp, Map<String,String> map,
- Map<ConstInfo,ConstInfo> cache)
- {
- String type = cp.getUtf8Info(typeDescriptor);
- String type2 = Descriptor.rename(type, map);
- if (type != type2)
- if (cache == null)
- typeDescriptor = cp.addUtf8Info(type2);
- else {
- cache.remove(this);
- typeDescriptor = cp.addUtf8Info(type2);
- cache.put(this, this);
- }
- }
-
- @Override
- public int copy(ConstPool src, ConstPool dest, Map<String,String> map)
- {
- String mname = src.getUtf8Info(memberName);
- String tdesc = src.getUtf8Info(typeDescriptor);
- tdesc = Descriptor.rename(tdesc, map);
- return dest.addNameAndTypeInfo(dest.addUtf8Info(mname),
- dest.addUtf8Info(tdesc));
- }
-
- @Override
- public void write(DataOutputStream out) throws IOException {
- out.writeByte(tag);
- out.writeShort(memberName);
- out.writeShort(typeDescriptor);
- }
-
- @Override
- public void print(PrintWriter out) {
- out.print("NameAndType #");
- out.print(memberName);
- out.print(", type #");
- out.println(typeDescriptor);
- }
- }
-
- abstract class MemberrefInfo extends ConstInfo
- {
- int classIndex;
- int nameAndTypeIndex;
-
- public MemberrefInfo(int cindex, int ntindex, int thisIndex)
- {
- super(thisIndex);
- classIndex = cindex;
- nameAndTypeIndex = ntindex;
- }
-
- public MemberrefInfo(DataInputStream in, int thisIndex)
- throws IOException
- {
- super(thisIndex);
- classIndex = in.readUnsignedShort();
- nameAndTypeIndex = in.readUnsignedShort();
- }
-
- @Override
- public int hashCode() { return (classIndex << 16) ^ nameAndTypeIndex; }
-
- @Override
- public boolean equals(Object obj) {
- if (obj instanceof MemberrefInfo) {
- MemberrefInfo mri = (MemberrefInfo)obj;
- return mri.classIndex == classIndex
- && mri.nameAndTypeIndex == nameAndTypeIndex
- && mri.getClass() == this.getClass();
- }
- return false;
- }
-
- @Override
- public int copy(ConstPool src, ConstPool dest, Map<String,String> map)
- {
- int classIndex2 = src.getItem(classIndex).copy(src, dest, map);
- int ntIndex2 = src.getItem(nameAndTypeIndex).copy(src, dest, map);
- return copy2(dest, classIndex2, ntIndex2);
- }
-
- abstract protected int copy2(ConstPool dest, int cindex, int ntindex);
-
- @Override
- public void write(DataOutputStream out) throws IOException
- {
- out.writeByte(getTag());
- out.writeShort(classIndex);
- out.writeShort(nameAndTypeIndex);
- }
-
- @Override
- public void print(PrintWriter out)
- {
- out.print(getTagName() + " #");
- out.print(classIndex);
- out.print(", name&type #");
- out.println(nameAndTypeIndex);
- }
-
- public abstract String getTagName();
- }
-
- class FieldrefInfo extends MemberrefInfo
- {
- static final int tag = 9;
-
- public FieldrefInfo(int cindex, int ntindex, int thisIndex)
- {
- super(cindex, ntindex, thisIndex);
- }
-
- public FieldrefInfo(DataInputStream in, int thisIndex)
- throws IOException
- {
- super(in, thisIndex);
- }
-
- @Override
- public int getTag() { return tag; }
-
- @Override
- public String getTagName() { return "Field"; }
-
- @Override
- protected int copy2(ConstPool dest, int cindex, int ntindex)
- {
- return dest.addFieldrefInfo(cindex, ntindex);
- }
- }
-
- class MethodrefInfo extends MemberrefInfo
- {
- static final int tag = 10;
-
- public MethodrefInfo(int cindex, int ntindex, int thisIndex)
- {
- super(cindex, ntindex, thisIndex);
- }
-
- public MethodrefInfo(DataInputStream in, int thisIndex)
- throws IOException
- {
- super(in, thisIndex);
- }
-
- @Override
- public int getTag() { return tag; }
-
- @Override
- public String getTagName() { return "Method"; }
-
- @Override
- protected int copy2(ConstPool dest, int cindex, int ntindex)
- {
- return dest.addMethodrefInfo(cindex, ntindex);
- }
- }
-
- class InterfaceMethodrefInfo extends MemberrefInfo
- {
- static final int tag = 11;
-
- public InterfaceMethodrefInfo(int cindex, int ntindex, int thisIndex)
- {
- super(cindex, ntindex, thisIndex);
- }
-
- public InterfaceMethodrefInfo(DataInputStream in, int thisIndex)
- throws IOException
- {
- super(in, thisIndex);
- }
-
- @Override
- public int getTag() { return tag; }
-
- @Override
- public String getTagName() { return "Interface"; }
-
- @Override
- protected int copy2(ConstPool dest, int cindex, int ntindex)
- {
- return dest.addInterfaceMethodrefInfo(cindex, ntindex);
- }
- }
-
- class StringInfo extends ConstInfo
- {
- static final int tag = 8;
- int string;
-
- public StringInfo(int str, int index)
- {
- super(index);
- string = str;
- }
-
- public StringInfo(DataInputStream in, int index) throws IOException
- {
- super(index);
- string = in.readUnsignedShort();
- }
-
- @Override
- public int hashCode() { return string; }
-
- @Override
- public boolean equals(Object obj)
- {
- return obj instanceof StringInfo && ((StringInfo)obj).string == string;
- }
-
- @Override
- public int getTag() { return tag; }
-
- @Override
- public int copy(ConstPool src, ConstPool dest, Map<String,String> map)
- {
- return dest.addStringInfo(src.getUtf8Info(string));
- }
-
- @Override
- public void write(DataOutputStream out) throws IOException
- {
- out.writeByte(tag);
- out.writeShort(string);
- }
-
- @Override
- public void print(PrintWriter out)
- {
- out.print("String #");
- out.println(string);
- }
- }
-
- class IntegerInfo extends ConstInfo
- {
- static final int tag = 3;
- int value;
-
- public IntegerInfo(int v, int index)
- {
- super(index);
- value = v;
- }
-
- public IntegerInfo(DataInputStream in, int index) throws IOException
- {
- super(index);
- value = in.readInt();
- }
-
- @Override
- public int hashCode() { return value; }
-
- @Override
- public boolean equals(Object obj)
- {
- return obj instanceof IntegerInfo && ((IntegerInfo)obj).value == value;
- }
-
- @Override
- public int getTag() { return tag; }
-
- @Override
- public int copy(ConstPool src, ConstPool dest, Map<String,String> map)
- {
- return dest.addIntegerInfo(value);
- }
-
- @Override
- public void write(DataOutputStream out) throws IOException
- {
- out.writeByte(tag);
- out.writeInt(value);
- }
-
- @Override
- public void print(PrintWriter out)
- {
- out.print("Integer ");
- out.println(value);
- }
- }
-
- class FloatInfo extends ConstInfo
- {
- static final int tag = 4;
- float value;
-
- public FloatInfo(float f, int index)
- {
- super(index);
- value = f;
- }
-
- public FloatInfo(DataInputStream in, int index) throws IOException
- {
- super(index);
- value = in.readFloat();
- }
-
- @Override
- public int hashCode() { return Float.floatToIntBits(value); }
-
- @Override
- public boolean equals(Object obj)
- {
- return obj instanceof FloatInfo && ((FloatInfo)obj).value == value;
- }
-
- @Override
- public int getTag() { return tag; }
-
- @Override
- public int copy(ConstPool src, ConstPool dest, Map<String,String> map)
- {
- return dest.addFloatInfo(value);
- }
-
- @Override
- public void write(DataOutputStream out) throws IOException
- {
- out.writeByte(tag);
- out.writeFloat(value);
- }
-
- @Override
- public void print(PrintWriter out)
- {
- out.print("Float ");
- out.println(value);
- }
- }
-
- class LongInfo extends ConstInfo
- {
- static final int tag = 5;
- long value;
-
- public LongInfo(long l, int index)
- {
- super(index);
- value = l;
- }
-
- public LongInfo(DataInputStream in, int index) throws IOException
- {
- super(index);
- value = in.readLong();
- }
-
- @Override
- public int hashCode() { return (int)(value ^ (value >>> 32)); }
-
- @Override
- public boolean equals(Object obj) {
- return obj instanceof LongInfo && ((LongInfo)obj).value == value;
- }
-
- @Override
- public int getTag() { return tag; }
-
- @Override
- public int copy(ConstPool src, ConstPool dest, Map<String,String> map)
- {
- return dest.addLongInfo(value);
- }
-
- @Override
- public void write(DataOutputStream out) throws IOException
- {
- out.writeByte(tag);
- out.writeLong(value);
- }
-
- @Override
- public void print(PrintWriter out)
- {
- out.print("Long ");
- out.println(value);
- }
- }
-
- class DoubleInfo extends ConstInfo
- {
- static final int tag = 6;
- double value;
-
- public DoubleInfo(double d, int index)
- {
- super(index);
- value = d;
- }
-
- public DoubleInfo(DataInputStream in, int index) throws IOException
- {
- super(index);
- value = in.readDouble();
- }
-
- @Override
- public int hashCode() {
- long v = Double.doubleToLongBits(value);
- return (int)(v ^ (v >>> 32));
- }
-
- @Override
- public boolean equals(Object obj)
- {
- return obj instanceof DoubleInfo
- && ((DoubleInfo)obj).value == value;
- }
-
- @Override
- public int getTag() { return tag; }
-
- @Override
- public int copy(ConstPool src, ConstPool dest, Map<String,String> map)
- {
- return dest.addDoubleInfo(value);
- }
-
- @Override
- public void write(DataOutputStream out) throws IOException
- {
- out.writeByte(tag);
- out.writeDouble(value);
- }
-
- @Override
- public void print(PrintWriter out)
- {
- out.print("Double ");
- out.println(value);
- }
- }
-
- class Utf8Info extends ConstInfo
- {
- static final int tag = 1;
- String string;
-
- public Utf8Info(String utf8, int index)
- {
- super(index);
- string = utf8;
- }
-
- public Utf8Info(DataInputStream in, int index)
- throws IOException
- {
- super(index);
- string = in.readUTF();
- }
-
- @Override
- public int hashCode() {
- return string.hashCode();
- }
-
- @Override
- public boolean equals(Object obj) {
- return obj instanceof Utf8Info
- && ((Utf8Info)obj).string.equals(string);
- }
-
- @Override
- public int getTag() { return tag; }
-
- @Override
- public int copy(ConstPool src, ConstPool dest,
- Map<String,String> map)
- {
- return dest.addUtf8Info(string);
- }
-
- @Override
- public void write(DataOutputStream out)
- throws IOException
- {
- out.writeByte(tag);
- out.writeUTF(string);
- }
-
- @Override
- public void print(PrintWriter out) {
- out.print("UTF8 \"");
- out.print(string);
- out.println("\"");
- }
- }
-
- class MethodHandleInfo extends ConstInfo {
- static final int tag = 15;
- int refKind, refIndex;
-
- public MethodHandleInfo(int kind, int referenceIndex, int index) {
- super(index);
- refKind = kind;
- refIndex = referenceIndex;
- }
-
- public MethodHandleInfo(DataInputStream in, int index)
- throws IOException
- {
- super(index);
- refKind = in.readUnsignedByte();
- refIndex = in.readUnsignedShort();
- }
-
- @Override
- public int hashCode() { return (refKind << 16) ^ refIndex; }
-
- @Override
- public boolean equals(Object obj)
- {
- if (obj instanceof MethodHandleInfo) {
- MethodHandleInfo mh = (MethodHandleInfo)obj;
- return mh.refKind == refKind && mh.refIndex == refIndex;
- }
- return false;
- }
-
- @Override
- public int getTag() { return tag; }
-
- @Override
- public int copy(ConstPool src, ConstPool dest,
- Map<String,String> map)
- {
- return dest.addMethodHandleInfo(refKind,
- src.getItem(refIndex).copy(src, dest, map));
- }
-
- @Override
- public void write(DataOutputStream out) throws IOException
- {
- out.writeByte(tag);
- out.writeByte(refKind);
- out.writeShort(refIndex);
- }
-
- @Override
- public void print(PrintWriter out) {
- out.print("MethodHandle #");
- out.print(refKind);
- out.print(", index #");
- out.println(refIndex);
- }
- }
-
- class MethodTypeInfo extends ConstInfo
- {
- static final int tag = 16;
- int descriptor;
-
- public MethodTypeInfo(int desc, int index)
- {
- super(index);
- descriptor = desc;
- }
-
- public MethodTypeInfo(DataInputStream in, int index)
- throws IOException
- {
- super(index);
- descriptor = in.readUnsignedShort();
- }
-
- @Override
- public int hashCode() { return descriptor; }
-
- @Override
- public boolean equals(Object obj)
- {
- if (obj instanceof MethodTypeInfo)
- return ((MethodTypeInfo)obj).descriptor == descriptor;
- return false;
- }
-
- @Override
- public int getTag() { return tag; }
-
- @Override
- public void renameClass(ConstPool cp, String oldName, String newName,
- Map<ConstInfo,ConstInfo> cache)
- {
- String desc = cp.getUtf8Info(descriptor);
- String desc2 = Descriptor.rename(desc, oldName, newName);
- if (desc != desc2)
- if (cache == null)
- descriptor = cp.addUtf8Info(desc2);
- else {
- cache.remove(this);
- descriptor = cp.addUtf8Info(desc2);
- cache.put(this, this);
- }
- }
-
- @Override
- public void renameClass(ConstPool cp, Map<String,String> map,
- Map<ConstInfo,ConstInfo> cache)
- {
- String desc = cp.getUtf8Info(descriptor);
- String desc2 = Descriptor.rename(desc, map);
- if (desc != desc2)
- if (cache == null)
- descriptor = cp.addUtf8Info(desc2);
- else {
- cache.remove(this);
- descriptor = cp.addUtf8Info(desc2);
- cache.put(this, this);
- }
- }
-
- @Override
- public int copy(ConstPool src, ConstPool dest, Map<String,String> map)
- {
- String desc = src.getUtf8Info(descriptor);
- desc = Descriptor.rename(desc, map);
- return dest.addMethodTypeInfo(dest.addUtf8Info(desc));
- }
-
- @Override
- public void write(DataOutputStream out) throws IOException
- {
- out.writeByte(tag);
- out.writeShort(descriptor);
- }
-
- @Override
- public void print(PrintWriter out) {
- out.print("MethodType #");
- out.println(descriptor);
- }
- }
-
- class InvokeDynamicInfo extends ConstInfo
- {
- static final int tag = 18;
- int bootstrap, nameAndType;
-
- public InvokeDynamicInfo(int bootstrapMethod,
- int ntIndex, int index)
- {
- super(index);
- bootstrap = bootstrapMethod;
- nameAndType = ntIndex;
- }
-
- public InvokeDynamicInfo(DataInputStream in, int index)
- throws IOException
- {
- super(index);
- bootstrap = in.readUnsignedShort();
- nameAndType = in.readUnsignedShort();
- }
-
- @Override
- public int hashCode() { return (bootstrap << 16) ^ nameAndType; }
-
- @Override
- public boolean equals(Object obj)
- {
- if (obj instanceof InvokeDynamicInfo) {
- InvokeDynamicInfo iv = (InvokeDynamicInfo)obj;
- return iv.bootstrap == bootstrap
- && iv.nameAndType == nameAndType;
- }
- return false;
- }
-
- @Override
- public int getTag() { return tag; }
-
- @Override
- public int copy(ConstPool src, ConstPool dest,
- Map<String,String> map)
- {
- return dest.addInvokeDynamicInfo(bootstrap,
- src.getItem(nameAndType).copy(src, dest, map));
- }
-
- @Override
- public void write(DataOutputStream out) throws IOException
- {
- out.writeByte(tag);
- out.writeShort(bootstrap);
- out.writeShort(nameAndType);
- }
-
- @Override
- public void print(PrintWriter out) {
- out.print("InvokeDynamic #");
- out.print(bootstrap);
- out.print(", name&type #");
- out.println(nameAndType);
- }
- }
-
- class DynamicInfo extends ConstInfo {
-
- static final int tag = 17;
- int bootstrap, nameAndType;
-
- public DynamicInfo(int bootstrapMethod, int ntIndex, int index) {
- super(index);
- bootstrap = bootstrapMethod;
- nameAndType = ntIndex;
- }
-
- public DynamicInfo(DataInputStream in, int index) throws IOException {
- super(index);
- bootstrap = in.readUnsignedShort();
- nameAndType = in.readUnsignedShort();
- }
-
- @Override
- public int hashCode() {
- return (bootstrap << 16) ^ nameAndType;
- }
-
- @Override
- public boolean equals(Object obj) {
- if (obj instanceof DynamicInfo) {
- DynamicInfo iv = (DynamicInfo)obj;
- return iv.bootstrap == bootstrap && iv.nameAndType == nameAndType;
- }
- return false;
- }
-
- @Override
- public int getTag() {
- return tag;
- }
-
- @Override
- public int copy(ConstPool src, ConstPool dest, Map<String, String> map) {
- return dest.addDynamicInfo(bootstrap, src.getItem(nameAndType).copy(src, dest, map));
- }
-
- @Override
- public void write(DataOutputStream out) throws IOException {
- out.writeByte(tag);
- out.writeShort(bootstrap);
- out.writeShort(nameAndType);
- }
-
- @Override
- public void print(PrintWriter out) {
- out.print("Dynamic #");
- out.print(bootstrap);
- out.print(", name&type #");
- out.println(nameAndType);
- }
- }
-
- class ModuleInfo extends ConstInfo
- {
- static final int tag = 19;
- int name;
-
- public ModuleInfo(int moduleName, int index)
- {
- super(index);
- name = moduleName;
- }
-
- public ModuleInfo(DataInputStream in, int index)
- throws IOException
- {
- super(index);
- name = in.readUnsignedShort();
- }
-
- @Override
- public int hashCode() { return name; }
-
- @Override
- public boolean equals(Object obj)
- {
- return obj instanceof ModuleInfo
- && ((ModuleInfo)obj).name == name;
- }
-
- @Override
- public int getTag() { return tag; }
-
- public String getModuleName(ConstPool cp)
- {
- return cp.getUtf8Info(name);
- }
-
- @Override
- public int copy(ConstPool src, ConstPool dest,
- Map<String,String> map)
- {
- String moduleName = src.getUtf8Info(name);
- int newName = dest.addUtf8Info(moduleName);
- return dest.addModuleInfo(newName);
- }
-
- @Override
- public void write(DataOutputStream out) throws IOException
- {
- out.writeByte(tag);
- out.writeShort(name);
- }
-
- @Override
- public void print(PrintWriter out) {
- out.print("Module #");
- out.println(name);
- }
- }
-
- class PackageInfo extends ConstInfo
- {
- static final int tag = 20;
- int name;
-
- public PackageInfo(int moduleName, int index)
- {
- super(index);
- name = moduleName;
- }
-
- public PackageInfo(DataInputStream in, int index)
- throws IOException
- {
- super(index);
- name = in.readUnsignedShort();
- }
-
- @Override
- public int hashCode() { return name; }
-
- @Override
- public boolean equals(Object obj) {
- return obj instanceof PackageInfo
- && ((PackageInfo)obj).name == name;
- }
-
- @Override
- public int getTag() { return tag; }
-
- public String getPackageName(ConstPool cp)
- {
- return cp.getUtf8Info(name);
- }
-
- @Override
- public int copy(ConstPool src, ConstPool dest,
- Map<String,String> map)
- {
- String packageName = src.getUtf8Info(name);
- int newName = dest.addUtf8Info(packageName);
- return dest.addModuleInfo(newName);
- }
-
- @Override
- public void write(DataOutputStream out) throws IOException
- {
- out.writeByte(tag);
- out.writeShort(name);
- }
-
- @Override
- public void print(PrintWriter out)
- {
- out.print("Package #");
- out.println(name);
- }
- }
|